package com.hh.demo_ui;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.hh.listeners.OnItemSpinnerClickListener;
import com.hh.ui.widget.UiPopupMenu;
import com.hh.ui.widget.UiSpinner;

public class Sample_Spinner extends Activity implements OnItemSpinnerClickListener {

	private String[] lTab={"Item 1","Item 2","Item 3","Item 4"};
	private UiSpinner _mSpinner2,_mSpinner1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sample_spinner);
		
		 _mSpinner1=(UiSpinner) findViewById(R.id.ASpinner_MySpinner1);	
		UiPopupMenu lMenuSpinner1=new UiPopupMenu(this, lTab);
		_mSpinner1.setPopupMenu(lMenuSpinner1);
		_mSpinner1.setOnItemPopupMenuClickListener(this);
		
		
		_mSpinner2=(UiSpinner) findViewById(R.id.ASpinner_MySpinner2);	
		UiPopupMenu lMenuSpinner2=new UiPopupMenu(this, lTab);
		
		lMenuSpinner2.setTextItemColor(Color.RED);
		lMenuSpinner2.setBackgroundColor(Color.YELLOW);
		lMenuSpinner2.setDividerItemsColor(Color.GREEN);
		
		_mSpinner2.setPopupMenu(lMenuSpinner2);
		_mSpinner2.setOnItemPopupMenuClickListener(this);
		_mSpinner2.setSelection(2);


	}

	@Override
	public void onItemClick(UiSpinner pSpinner,View v, int position) {
		
		if(pSpinner.getId()==R.id.ASpinner_MySpinner1)
			Toast.makeText(this, "Clicked element :"+_mSpinner1.getTextSelection(), Toast.LENGTH_SHORT).show();
		
		else if(pSpinner.getId()==R.id.ASpinner_MySpinner2)
			Toast.makeText(this, "Clicked element :"+_mSpinner2.getTextSelection(), Toast.LENGTH_SHORT).show();
	}

}
